<input id="id" type="hidden" value="<?php echo $data['id']; ?>"/>
    <div class="page-heading">
            		<h1><i class=' icon-newspaper-1'></i>GALERIAS</h1>
            		            	</div>
            	<!-- Page Heading End-->
				
				<!-- Begin Inbox -->
				<div class="box-messages">
						<div class="col-md-3">
							<!-- Sidebar Message -->

							<div class="btn-group new-message-btns stacked">
								<a id="modificar_galeria" href="#" class="btn btn-primary btn-lg btn-block text-left">Modificar</a>
							</div>
							<div class="list-group menu-message">
							  <a href="inbox.html" class="list-group-item"><i class="icon-inbox"></i> Nom <span class="badge pull-right"><?php echo $data['galeria'][0]->nom; ?></span></a>
							  <a href="#fakelink" class="list-group-item"><i class="icon-pencil"></i> Secció <span class="badge bg-green-1 pull-right"><?php echo $data['seccio']; ?></span></a>
							  <a href="#fakelink" class="list-group-item"><i class="icon-star"></i> Imatges <span class="badge bg-green-1 pull-right"><?php echo count($data['fotos']); ?></span></a>
							  
							</div>
							
							<div class="list-group menu-folders">
								<div class="col-md-6">
							  		<p style="text-align: right; font-size: 1.8em">Visible</p>
							  	</div>
							  	<div id="visible" class="col-md-6">
							  		<div class="visible iswitch ios-switch-primary <?php echo $data['estado']; ?>"><div class="on-background background-fill"></div><div class="state-background background-fill"></div><div class="handle"></div></div>
								</div>
							  	
							</div>
							  

							</div>
						</div><!-- ENd div .col-md-2 -->

						<div class="col-md-9">							
								<div class="col-sm-2">
									<div class="widget">
										<div class="btn-group new-message-btns stacked">
											<a href="<?php echo URL; ?>nova_galeria" class="btn btn-primary btn-lg btn-block text-left"> Crear Galeria</a>
										</div>
									</div>
								</div>
                                <div class="col-sm-2">
									<div class="widget">
										<div class="btn-group new-message-btns stacked">
											<a href="<?php echo URL; ?>galerias" class="btn btn-primary btn-lg btn-block text-left"> Galeries</a>
										</div>
									</div>
								</div>
								<div class="col-sm-2">
									<div class="widget">
										<div class="btn-group new-message-btns stacked">
											<a href="<?php echo URL; ?>seccions" class="btn btn-primary btn-lg btn-block text-left">Seccions</a>
										</div>
									</div>
								</div>
						
									</p>
								<div class="row" >
										
									</div>
									
									<div class="row" id="plantilla_galeria">
										<div class="box-info animated fadeInDown">
											<h2><strong>Galeria</strong> Imatges</h2>
											    
                                                <input id="afegir_imatges" style="padding: 5px" type="button" value="Afegir Imatges"/> 
                                                <div id="afegir_imatges_drop" style="display: none" class="col-sm-12 mail-body" id="plantilla_defecto">
							                         <form action="subir_fotos" method="POST" id="my-awesome-dropzone" class="dropzone" style="margin-bottom: 20px;">
                                                     <input type="hidden" name="ruta" value="hola"/>
                                                    </form>
                                                </div>
												<div class="gallery-wrap">
												
													<?php foreach($data['fotos'] as $foto){?>
														<div class="column-4">
															<div class="inner">
																<a title="Image title here" href="<?php echo URL; ?>assets/fotos/<?php echo $foto->nom_galeria;?>/original/<?php echo $foto->nom;?>" class="zooming">
																<div class="img-wrap">
																	<img class="mfp-fade" title="Image title here" alt="Image gallery" src="<?php echo URL; ?>assets/fotos/<?php echo $foto->nom_galeria;?>/web/<?php echo $foto->nom;?>">
																</div>
																<div class="caption-hover">
																<?php echo($foto->nom);?>
                                                                <span id="<?php echo($foto->id);?>" class="borrar_foto" style="float: right; cursor: pointer; font-weight: 700">X</span>
																</div>
																</a>
															</div>
														</div>
												
													<?php } ?>
											
													
												</div>

										
										</div>
									
									</div>
									
								</div>
							</div>
						</div>
					</div>

 <script>
 
   var myDropzone;
        Dropzone.options.myAwesomeDropzone = {
        
        autoProcessQueue: false,
        
        init: function() {
            
            myDropzone = this;
            
            this.on("success", function(file, messageOrDataFromServer, myEvent) {
                alert(messageOrDataFromServer)
                    
            });  
            
              
            } 
        }; 
        
                
    $('#modificar_galeria').click(function(e){
            e.preventDefault();
            e.stopPropagation();
                        
            myDropzone.processQueue();
        }); 
 
 var id = $('#id').val();
 $('#visible').click(function(){
    if($('.visible').hasClass('on')){
        $.ajax({
            type: "POST",
            url: "<?php echo URL; ?>activar_galeria",
            data: { id: id, estado: 0 }
        })
            .done(function( msg ) {
                $('.visible').removeClass('on');
                $('.visible').addClass('off');                
            });   
    } else {
    $.ajax({
        type: "POST",
        url: "<?php echo URL; ?>activar_galeria",
        data: { id: id, estado: 1 }
        })
        .done(function( msg ) {
            $('.visible').addClass('on');
            $('.visible').removeClass('off');                            
        });
    }
 })
 
 $('#afegir_imatges').click(function(){
    $(this).hide();
    $('#afegir_imatges_drop').show();
 })
 
 $('.borrar_foto').click(function(e){
    $('.mfp-content').html('HOLAAAAAAAAAAAAAA')
 })
 
 </script>